<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html class="js" xml:lang="en" xmlns="http://www.w3.org/1999/xhtml" lang="en"><head>


  
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>Android SQLite Basics: creating and using a database, and working with sqlite3 | Screaming Penguin</title>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="shortcut icon" href="http://www.screaming-penguin.com/favicon.ico" type="image/x-icon">
    <link type="text/css" rel="stylesheet" media="all" href="database_files/aggregator.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/google_cse.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/node.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/shCore.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/shThemeDefault.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/defaults.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/system.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/system-menus.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/tagadelic.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/user.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/views.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/comment.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/openid.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/style.css">
<link type="text/css" rel="stylesheet" media="all" href="database_files/barroness.css">
    <script src="database_files/ga.js" async="" type="text/javascript"></script><script src="database_files/googleapis.js"></script><script type="text/javascript" src="database_files/jquery.js"></script>
<script type="text/javascript" src="database_files/drupal.js"></script>
<script type="text/javascript" src="database_files/googleanalytics.js"></script>
<script type="text/javascript" src="database_files/shCore.js"></script>
<script type="text/javascript" src="database_files/shBrushAS3.js"></script>
<script type="text/javascript" src="database_files/shBrushBash.js"></script>
<script type="text/javascript" src="database_files/shBrushCss.js"></script>
<script type="text/javascript" src="database_files/shBrushGroovy.js"></script>
<script type="text/javascript" src="database_files/shBrushJava.js"></script>
<script type="text/javascript" src="database_files/shBrushPlain.js"></script>
<script type="text/javascript" src="database_files/shBrushXml.js"></script>
<script type="text/javascript" src="database_files/openid.js"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, { "basePath": "/", "googleanalytics": { "trackOutgoing": 1, "trackMailto": 1, "trackDownload": 1, "trackDownloadExtensions": "7z|aac|arc|arj|asf|asx|avi|bin|csv|doc|exe|flv|gif|gz|gzip|hqx|jar|jpe?g|js|mp(2|3|4|e?g)|mov(ie)?|msi|msp|pdf|phps|png|ppt|qtm?|ra(m|r)?|sea|sit|tar|tgz|torrent|txt|wav|wma|wmv|wpd|xls|xml|z|zip" }, "syntaxhighlighter": null });
//--><!]]>
</script>
    <!--[if lte IE 7]>
    <style type="text/css" media="all">@import "/sites/all/themes/barron/ie-fixes.css";</style>
    <![endif]-->
  </head><body>
    <div id="container">
      <div id="header">
        <div id="nav">
                                        </div><!-- /nav -->
        <div id="logo-wrapper">
                    <div id="logo"><a href="http://www.screaming-penguin.com/" title="Home"><img src="database_files/barroness_logo.png" alt="Home"></a></div>          <h1 class="site-name"><a href="http://www.screaming-penguin.com/" title="Home">Screaming Penguin</a></h1>          <h2 class="site-slogan">- Source Does Matter</h2>        </div><!-- /logo-wrapper-->
      </div><!-- /header-->

      <div id="content">
                <div class="breadcrumb"><a href="http://www.screaming-penguin.com/">Home</a> :: <a href="http://www.screaming-penguin.com/blog">Blogs</a> :: <a href="http://www.screaming-penguin.com/blog/1">charlie.collins's blog</a></div>        <h2 class="page-title">Android SQLite Basics: creating and using a database, and working with sqlite3</h2>
        <div class="tabs"></div>
                	              <div id="node-7742" class="node">

  
      
  <span class="submitted">
    Submitted by charlie.collins on Sun, 01/17/2010 - 14:48  </span>
    
      <div class="taxonomy">
      Tagged: <ul class="links inline"><li class="taxonomy_term_17 first last"><a href="http://www.screaming-penguin.com/taxonomy/term/17" rel="tag" title="">Tutorials</a></li>
</ul>    </div>
      
  <div class="content">
    <b>UPDATE DISCLAIMER</b><i>This is one way to do direct DB access 
with SQLite on Android, but it's not the only way. I have modified the 
pattern I personally use somewhat, and it's quite a bit different from 
the time this article was written (this article is old). I plan to 
update this article at some point when I have time, but for now just 
keep in mind that this is meant to get you started, but not be a 
complete/comprehensive/exclusive  approach.
<br>
Also, after a server crash the formatting, and some images were lost, 
these items will be fixed as soon as I get a chance, sorry. </i>
<br><br>

Because I often have to revisit this stuff myself, I thought I would 
write a quick reference tutorial on creating and using a database with 
an Android application. This isn't terribly well covered in the Android 
docs, and though many <i>ContentProvider</i> tutorials exist (<a href="http://unlocking-android.googlecode.com/svn/chapter5/trunk/ProviderWidgets/">such as the Unlocking Android code for chapter 5</a>,
 and the NotePad tutorial included with the SDK), and these help a lot 
with general database concepts, they are really more complicated than 
what a basic application needs - a database to store and retrieve stuff.

I will walk through the code and tools for an oversimplified example 
here, with the ultimate goal of inserting and retrieving some data from 
an database in an Android app, and then examining the database using a 
shell and the <b>sqlite3</b> command line tool. The entire code for this example is available here: <a href="http://totsp.com/svn/repo/AndroidExamples/trunk/">http://totsp.com/svn/repo/AndroidExamples/trunk/</a>.

<b>NOTE</b> <i>This code was updated for <a href="http://www.screaming-penguin.com/node/7746">part 2</a>, and <a href="http://www.screaming-penguin.com/node/7749">part 3</a>
 of this series, so it no longer exactly matches this example -- it's 
still a working sample app, it just now does a bit more than the 
original.</i>

First, to get this rolling, we need to create an Android application 
that HAS a database. We could use any built in application that has a 
database just to explore it, such as <i>com.android.alarmclock</i>), but
 we are going to create one here for completeness. After it's setup, the
 interface for our application will look like the screen shot shown 
below:
<br>
<img src="database_files/android_examples_main.htm" alt="Android Examples" width="400" height="250">

Yeah this project is ugly, and it only has one <i>Activity</i>, but for 
our purposes here we really aren't trying to create a fancy UI (or 
anything that is complicated on any level). To create this project we 
will use the <a href="http://www.eclipse.org/">Eclipse IDE</a>. Along with Eclipse, we will also of course need to have <a href="http://developer.android.com/intl/es/sdk/index.html">the Android SDK</a> with the correct Eclipse ADT Plug-In as a prerequisite too (to get that see the instructions at the aforelinked site). 
<br><br>
<b>1.</b> To create a basic Android project, we will simply select <b>File-&gt;New-&gt;Other-&gt;Android-&gt;Android Project</b>. On the dialog we will then enter the application name <b>AndroidExamples</b>, and the package name <i>com.totsp.androidexamples</i>, along with some other settings, as shown in the figure below:
<br>
<img src="database_files/android_examples_create_project.htm" alt="Create Android Project with Eclipse">
<br><br>
The target we choose must be one that we have installed when we setup or
 configued the Android SDK. For this example we are using 1.6 because it
 is still the most common Android platform that user's phones are 
running (we are using the 2.1 SDK, with a 1.6 Target). We will also set 
the "Min SDK Version" to "4" which is SDK 1.6. This is a confusing part 
of the Android setup at this point (names are transposed from "sdk" to 
"api" and such) but the details are <a href="http://developer.android.com/intl/es/guide/appendix/api-levels.html">documented somewhat</a>.
<br><br>
Once we have the default sample project in place, the next step will be 
to create a helper class that can create the database and encapsulate 
other SQL details. We will call this class <i>DataHelper</i>. Within this class (at the end) we will include an important inner class that provides a <i>SQLiteOpenHelper</i>. The full code is shown below:
<br><br>
<div><div id="highlighter_625991" class="syntaxhighlighter  java"><div class="toolbar"><span><a href="#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div><div class="line number20 index19 alt1">20</div><div class="line number21 index20 alt2">21</div><div class="line number22 index21 alt1">22</div><div class="line number23 index22 alt2">23</div><div class="line number24 index23 alt1">24</div><div class="line number25 index24 alt2">25</div><div class="line number26 index25 alt1">26</div><div class="line number27 index26 alt2">27</div><div class="line number28 index27 alt1">28</div><div class="line number29 index28 alt2">29</div><div class="line number30 index29 alt1">30</div><div class="line number31 index30 alt2">31</div><div class="line number32 index31 alt1">32</div><div class="line number33 index32 alt2">33</div><div class="line number34 index33 alt1">34</div><div class="line number35 index34 alt2">35</div><div class="line number36 index35 alt1">36</div><div class="line number37 index36 alt2">37</div><div class="line number38 index37 alt1">38</div><div class="line number39 index38 alt2">39</div><div class="line number40 index39 alt1">40</div><div class="line number41 index40 alt2">41</div><div class="line number42 index41 alt1">42</div><div class="line number43 index42 alt2">43</div><div class="line number44 index43 alt1">44</div><div class="line number45 index44 alt2">45</div><div class="line number46 index45 alt1">46</div><div class="line number47 index46 alt2">47</div><div class="line number48 index47 alt1">48</div><div class="line number49 index48 alt2">49</div><div class="line number50 index49 alt1">50</div><div class="line number51 index50 alt2">51</div><div class="line number52 index51 alt1">52</div><div class="line number53 index52 alt2">53</div><div class="line number54 index53 alt1">54</div><div class="line number55 index54 alt2">55</div><div class="line number56 index55 alt1">56</div><div class="line number57 index56 alt2">57</div><div class="line number58 index57 alt1">58</div><div class="line number59 index58 alt2">59</div><div class="line number60 index59 alt1">60</div><div class="line number61 index60 alt2">61</div><div class="line number62 index61 alt1">62</div><div class="line number63 index62 alt2">63</div><div class="line number64 index63 alt1">64</div><div class="line number65 index64 alt2">65</div><div class="line number66 index65 alt1">66</div><div class="line number67 index66 alt2">67</div><div class="line number68 index67 alt1">68</div><div class="line number69 index68 alt2">69</div><div class="line number70 index69 alt1">70</div><div class="line number71 index70 alt2">71</div><div class="line number72 index71 alt1">72</div><div class="line number73 index72 alt2">73</div><div class="line number74 index73 alt1">74</div><div class="line number75 index74 alt2">75</div><div class="line number76 index75 alt1">76</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="java keyword">package</code> <code class="java plain">com.totsp.androidexamples;</code></div><div class="line number2 index1 alt1">&nbsp;</div><div class="line number3 index2 alt2"><code class="java keyword">import</code> <code class="java plain">android.content.Context;</code></div><div class="line number4 index3 alt1"><code class="java keyword">import</code> <code class="java plain">android.database.Cursor;</code></div><div class="line number5 index4 alt2"><code class="java keyword">import</code> <code class="java plain">android.database.sqlite.SQLiteDatabase;</code></div><div class="line number6 index5 alt1"><code class="java keyword">import</code> <code class="java plain">android.database.sqlite.SQLiteOpenHelper;</code></div><div class="line number7 index6 alt2"><code class="java keyword">import</code> <code class="java plain">android.database.sqlite.SQLiteStatement;</code></div><div class="line number8 index7 alt1"><code class="java keyword">import</code> <code class="java plain">android.util.Log;</code></div><div class="line number9 index8 alt2">&nbsp;</div><div class="line number10 index9 alt1"><code class="java keyword">import</code> <code class="java plain">java.util.ArrayList;</code></div><div class="line number11 index10 alt2"><code class="java keyword">import</code> <code class="java plain">java.util.List;</code></div><div class="line number12 index11 alt1">&nbsp;</div><div class="line number13 index12 alt2"><code class="java keyword">public</code> <code class="java keyword">class</code> <code class="java plain">DataHelper {</code></div><div class="line number14 index13 alt1">&nbsp;</div><div class="line number15 index14 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java keyword">static</code> <code class="java keyword">final</code> <code class="java plain">String DATABASE_NAME = </code><code class="java string">"example.db"</code><code class="java plain">;</code></div><div class="line number16 index15 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java keyword">static</code> <code class="java keyword">final</code> <code class="java keyword">int</code> <code class="java plain">DATABASE_VERSION = </code><code class="java value">1</code><code class="java plain">;</code></div><div class="line number17 index16 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java keyword">static</code> <code class="java keyword">final</code> <code class="java plain">String TABLE_NAME = </code><code class="java string">"table1"</code><code class="java plain">;</code></div><div class="line number18 index17 alt1">&nbsp;</div><div class="line number19 index18 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java plain">Context context;</code></div><div class="line number20 index19 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java plain">SQLiteDatabase db;</code></div><div class="line number21 index20 alt2">&nbsp;</div><div class="line number22 index21 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java plain">SQLiteStatement insertStmt;</code></div><div class="line number23 index22 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java keyword">static</code> <code class="java keyword">final</code> <code class="java plain">String INSERT = </code><code class="java string">"insert into "</code></div><div class="line number24 index23 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">+ TABLE_NAME + </code><code class="java string">"(name) values (?)"</code><code class="java plain">;</code></div><div class="line number25 index24 alt2">&nbsp;</div><div class="line number26 index25 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java plain">DataHelper(Context context) {</code></div><div class="line number27 index26 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.context = context;</code></div><div class="line number28 index27 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">OpenHelper openHelper = </code><code class="java keyword">new</code> <code class="java plain">OpenHelper(</code><code class="java keyword">this</code><code class="java plain">.context);</code></div><div class="line number29 index28 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.db = openHelper.getWritableDatabase();</code></div><div class="line number30 index29 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.insertStmt = </code><code class="java keyword">this</code><code class="java plain">.db.compileStatement(INSERT);</code></div><div class="line number31 index30 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number32 index31 alt1">&nbsp;</div><div class="line number33 index32 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java keyword">long</code> <code class="java plain">insert(String name) {</code></div><div class="line number34 index33 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.insertStmt.bindString(</code><code class="java value">1</code><code class="java plain">, name);</code></div><div class="line number35 index34 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">return</code> <code class="java keyword">this</code><code class="java plain">.insertStmt.executeInsert();</code></div><div class="line number36 index35 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number37 index36 alt2">&nbsp;</div><div class="line number38 index37 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java keyword">void</code> <code class="java plain">deleteAll() {</code></div><div class="line number39 index38 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.db.delete(TABLE_NAME, </code><code class="java keyword">null</code><code class="java plain">, </code><code class="java keyword">null</code><code class="java plain">);</code></div><div class="line number40 index39 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number41 index40 alt2">&nbsp;</div><div class="line number42 index41 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java plain">List&lt;String&gt; selectAll() {</code></div><div class="line number43 index42 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">List&lt;String&gt; list = </code><code class="java keyword">new</code> <code class="java plain">ArrayList&lt;String&gt;();</code></div><div class="line number44 index43 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">Cursor cursor = </code><code class="java keyword">this</code><code class="java plain">.db.query(TABLE_NAME, </code><code class="java keyword">new</code> <code class="java plain">String[] { </code><code class="java string">"name"</code> <code class="java plain">}, </code></div><div class="line number45 index44 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">null</code><code class="java plain">, </code><code class="java keyword">null</code><code class="java plain">, </code><code class="java keyword">null</code><code class="java plain">, </code><code class="java keyword">null</code><code class="java plain">, </code><code class="java string">"name desc"</code><code class="java plain">);</code></div><div class="line number46 index45 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">if</code> <code class="java plain">(cursor.moveToFirst()) {</code></div><div class="line number47 index46 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">do</code> <code class="java plain">{</code></div><div class="line number48 index47 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">list.add(cursor.getString(</code><code class="java value">0</code><code class="java plain">)); </code></div><div class="line number49 index48 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">} </code><code class="java keyword">while</code> <code class="java plain">(cursor.moveToNext());</code></div><div class="line number50 index49 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number51 index50 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">if</code> <code class="java plain">(cursor != </code><code class="java keyword">null</code> <code class="java plain">&amp;&amp; !cursor.isClosed()) {</code></div><div class="line number52 index51 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">cursor.close();</code></div><div class="line number53 index52 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number54 index53 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">return</code> <code class="java plain">list;</code></div><div class="line number55 index54 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number56 index55 alt1">&nbsp;</div><div class="line number57 index56 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java keyword">static</code> <code class="java keyword">class</code> <code class="java plain">OpenHelper </code><code class="java keyword">extends</code> <code class="java plain">SQLiteOpenHelper {</code></div><div class="line number58 index57 alt1">&nbsp;</div><div class="line number59 index58 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">OpenHelper(Context context) {</code></div><div class="line number60 index59 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">super</code><code class="java plain">(context, DATABASE_NAME, </code><code class="java keyword">null</code><code class="java plain">, DATABASE_VERSION);</code></div><div class="line number61 index60 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number62 index61 alt1">&nbsp;</div><div class="line number63 index62 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java color1">@Override</code></div><div class="line number64 index63 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java keyword">void</code> <code class="java plain">onCreate(SQLiteDatabase db) {</code></div><div class="line number65 index64 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">db.execSQL(</code><code class="java string">"CREATE TABLE "</code> <code class="java plain">+ TABLE_NAME + " </code></div><div class="line number66 index65 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">(id INTEGER PRIMARY KEY, name TEXT)");</code></div><div class="line number67 index66 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number68 index67 alt1">&nbsp;</div><div class="line number69 index68 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java color1">@Override</code></div><div class="line number70 index69 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java keyword">void</code> <code class="java plain">onUpgrade(SQLiteDatabase db, </code><code class="java keyword">int</code> <code class="java plain">oldVersion, </code><code class="java keyword">int</code> <code class="java plain">newVersion) {</code></div><div class="line number71 index70 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">Log.w(</code><code class="java string">"Example"</code><code class="java plain">, </code><code class="java string">"Upgrading database, this will drop tables and recreate."</code><code class="java plain">);</code></div><div class="line number72 index71 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">db.execSQL(</code><code class="java string">"DROP TABLE IF EXISTS "</code> <code class="java plain">+ TABLE_NAME);</code></div><div class="line number73 index72 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">onCreate(db);</code></div><div class="line number74 index73 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number75 index74 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number76 index75 alt1"><code class="java plain">}</code></div></div></td></tr></tbody></table></div></div>

This class is simple, as I have said it would be. For example it's using
 a database with one table and one column, but, it still covers some 
core Android concepts. We won't go into great detail concerning this 
class here, it should be mostly understandable from the code, but a few 
important things to note are: 
<ul>
<li>it includes an implementation of <i>SQLiteOpenHelper</i> as an inner class</li>
<li>it demonstrates two different ways of interacting with the database in code, with a <i>SQLiteStatement</i> for inserts (which has the advantage of being pre-compiled, versus regular, but easier <a href="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html"><i>SQLiteDatabase.query()</i></a> methods you probably also want to be familiar with), and directly by querying for selects</li>
<li>it shows a useful pattern (though again, oversimplified here) of exposing data persistence/retrieval methods on the helper</li>
</ul>
To use this class from the default <i>Main.java</i> class that we let the Android Eclipse Plug-In generate, we will modify it a bit to create an instance of our <i>DataHelper</i>
 and then use it to create and retrieve data as seen below.(NOTE: In the
 real world you might do this once per application, say by using the oft
 overlooked Android <i>Application</i> class, where you could create the <i>DataHelper</i> once, and then expose the reference to other classes, rather than in <i>Activity.onCreate()</i>):
<br><br>
<div><div id="highlighter_806868" class="syntaxhighlighter  java"><div class="toolbar"><span><a href="#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div><div class="line number20 index19 alt1">20</div><div class="line number21 index20 alt2">21</div><div class="line number22 index21 alt1">22</div><div class="line number23 index22 alt2">23</div><div class="line number24 index23 alt1">24</div><div class="line number25 index24 alt2">25</div><div class="line number26 index25 alt1">26</div><div class="line number27 index26 alt2">27</div><div class="line number28 index27 alt1">28</div><div class="line number29 index28 alt2">29</div><div class="line number30 index29 alt1">30</div><div class="line number31 index30 alt2">31</div><div class="line number32 index31 alt1">32</div><div class="line number33 index32 alt2">33</div><div class="line number34 index33 alt1">34</div><div class="line number35 index34 alt2">35</div><div class="line number36 index35 alt1">36</div><div class="line number37 index36 alt2">37</div><div class="line number38 index37 alt1">38</div><div class="line number39 index38 alt2">39</div><div class="line number40 index39 alt1">40</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="java keyword">package</code> <code class="java plain">com.totsp.androidexamples;</code></div><div class="line number2 index1 alt1">&nbsp;</div><div class="line number3 index2 alt2"><code class="java keyword">import</code> <code class="java plain">android.app.Activity;</code></div><div class="line number4 index3 alt1"><code class="java keyword">import</code> <code class="java plain">android.os.Bundle;</code></div><div class="line number5 index4 alt2"><code class="java keyword">import</code> <code class="java plain">android.util.Log;</code></div><div class="line number6 index5 alt1"><code class="java keyword">import</code> <code class="java plain">android.widget.TextView;</code></div><div class="line number7 index6 alt2">&nbsp;</div><div class="line number8 index7 alt1"><code class="java keyword">import</code> <code class="java plain">java.util.List;</code></div><div class="line number9 index8 alt2">&nbsp;</div><div class="line number10 index9 alt1"><code class="java keyword">public</code> <code class="java keyword">class</code> <code class="java plain">Main </code><code class="java keyword">extends</code> <code class="java plain">Activity {</code></div><div class="line number11 index10 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code>&nbsp;</div><div class="line number12 index11 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java plain">TextView output;</code></div><div class="line number13 index12 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code>&nbsp;</div><div class="line number14 index13 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code><code class="java keyword">private</code> <code class="java plain">DataHelper dh;</code></div><div class="line number15 index14 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;</code>&nbsp;</div><div class="line number16 index15 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java color1">@Override</code></div><div class="line number17 index16 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">public</code> <code class="java keyword">void</code> <code class="java plain">onCreate(Bundle savedInstanceState) {</code></div><div class="line number18 index17 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">super</code><code class="java plain">.onCreate(savedInstanceState);</code></div><div class="line number19 index18 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">setContentView(R.layout.main);</code></div><div class="line number20 index19 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>&nbsp;</div><div class="line number21 index20 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.output = (TextView) </code><code class="java keyword">this</code><code class="java plain">.findViewById(R.id.out_text);</code></div><div class="line number22 index21 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>&nbsp;</div><div class="line number23 index22 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.dh = </code><code class="java keyword">new</code> <code class="java plain">DataHelper(</code><code class="java keyword">this</code><code class="java plain">);</code></div><div class="line number24 index23 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.dh.deleteAll();</code></div><div class="line number25 index24 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.dh.insert(</code><code class="java string">"Porky Pig"</code><code class="java plain">);</code></div><div class="line number26 index25 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.dh.insert(</code><code class="java string">"Foghorn Leghorn"</code><code class="java plain">);</code></div><div class="line number27 index26 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.dh.insert(</code><code class="java string">"Yosemite Sam"</code><code class="java plain">);&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </code></div><div class="line number28 index27 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">List&lt;String&gt; names = </code><code class="java keyword">this</code><code class="java plain">.dh.selectAll();</code></div><div class="line number29 index28 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">StringBuilder sb = </code><code class="java keyword">new</code> <code class="java plain">StringBuilder();</code></div><div class="line number30 index29 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">sb.append(</code><code class="java string">"Names in database:\n"</code><code class="java plain">);</code></div><div class="line number31 index30 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">for</code> <code class="java plain">(String name : names) {</code></div><div class="line number32 index31 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">sb.append(name + </code><code class="java string">"\n"</code><code class="java plain">);</code></div><div class="line number33 index32 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number34 index33 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>&nbsp;</div><div class="line number35 index34 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">Log.d(</code><code class="java string">"EXAMPLE"</code><code class="java plain">, </code><code class="java string">"names size - "</code> <code class="java plain">+ names.size());</code></div><div class="line number36 index35 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>&nbsp;</div><div class="line number37 index36 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java keyword">this</code><code class="java plain">.output.setText(sb.toString());</code></div><div class="line number38 index37 alt1"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code>&nbsp;</div><div class="line number39 index38 alt2"><code class="java spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="java plain">}</code></div><div class="line number40 index39 alt1"><code class="java plain">}</code></div></div></td></tr></tbody></table></div></div>
<br><br>
For this class to work, we also need to change the <i>main.xml</i> layout file it relies on. We need to include one additional <i>TextView</i> for the output, as seen below:
<br><br>
<div><div id="highlighter_231610" class="syntaxhighlighter  xml"><div class="toolbar"><span><a href="#" class="toolbar_item command_help help">?</a></span></div><table border="0" cellpadding="0" cellspacing="0"><tbody><tr><td class="gutter"><div class="line number1 index0 alt2">1</div><div class="line number2 index1 alt1">2</div><div class="line number3 index2 alt2">3</div><div class="line number4 index3 alt1">4</div><div class="line number5 index4 alt2">5</div><div class="line number6 index5 alt1">6</div><div class="line number7 index6 alt2">7</div><div class="line number8 index7 alt1">8</div><div class="line number9 index8 alt2">9</div><div class="line number10 index9 alt1">10</div><div class="line number11 index10 alt2">11</div><div class="line number12 index11 alt1">12</div><div class="line number13 index12 alt2">13</div><div class="line number14 index13 alt1">14</div><div class="line number15 index14 alt2">15</div><div class="line number16 index15 alt1">16</div><div class="line number17 index16 alt2">17</div><div class="line number18 index17 alt1">18</div><div class="line number19 index18 alt2">19</div></td><td class="code"><div class="container"><div class="line number1 index0 alt2"><code class="xml plain">&lt;?</code><code class="xml keyword">xml</code> <code class="xml color1">version</code><code class="xml plain">=</code><code class="xml string">"1.0"</code> <code class="xml color1">encoding</code><code class="xml plain">=</code><code class="xml string">"utf-8"</code><code class="xml plain">?&gt;</code></div><div class="line number2 index1 alt1"><code class="xml plain">&lt;</code><code class="xml keyword">ScrollView</code></div><div class="line number3 index2 alt2"><code class="xml spaces">&nbsp;&nbsp;</code><code class="xml color1">xmlns:android</code><code class="xml plain">=</code><code class="xml string">"<a href="http://schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android</a>"</code></div><div class="line number4 index3 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml color1">android:layout_width</code><code class="xml plain">=</code><code class="xml string">"fill_parent"</code></div><div class="line number5 index4 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml color1">android:layout_height</code><code class="xml plain">=</code><code class="xml string">"wrap_content"</code><code class="xml plain">&gt;</code></div><div class="line number6 index5 alt1"><code class="xml spaces">&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">LinearLayout</code> <code class="xml color1">xmlns:android</code><code class="xml plain">=</code></div><div class="line number7 index6 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml string">"<a href="http://schemas.android.com/apk/res/android">http://schemas.android.com/apk/res/android</a>"</code></div><div class="line number8 index7 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml color1">android:orientation</code><code class="xml plain">=</code><code class="xml string">"vertical"</code></div><div class="line number9 index8 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml color1">android:layout_width</code><code class="xml plain">=</code><code class="xml string">"fill_parent"</code></div><div class="line number10 index9 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml color1">android:layout_height</code><code class="xml plain">=</code><code class="xml string">"fill_parent"</code><code class="xml plain">&gt;</code></div><div class="line number11 index10 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">TextView</code> <code class="xml color1">android:layout_width</code><code class="xml plain">=</code><code class="xml string">"fill_parent"</code></div><div class="line number12 index11 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml color1">android:layout_height</code><code class="xml plain">=</code><code class="xml string">"wrap_content"</code></div><div class="line number13 index12 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml color1">android:text</code><code class="xml plain">=</code><code class="xml string">"@string/hello"</code> <code class="xml plain">/&gt;</code></div><div class="line number14 index13 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml plain">&lt;</code><code class="xml keyword">TextView</code> <code class="xml color1">android:id</code><code class="xml plain">=</code><code class="xml string">"@+id/out_text"</code></div><div class="line number15 index14 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml color1">android:layout_width</code><code class="xml plain">=</code><code class="xml string">"fill_parent"</code></div><div class="line number16 index15 alt1"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml color1">android:layout_height</code><code class="xml plain">=</code><code class="xml string">"wrap_content"</code></div><div class="line number17 index16 alt2"><code class="xml spaces">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</code><code class="xml color1">android:text</code><code class="xml plain">=</code><code class="xml string">""</code> <code class="xml plain">/&gt;</code></div><div class="line number18 index17 alt1"><code class="xml spaces">&nbsp;&nbsp;</code><code class="xml plain">&lt;/</code><code class="xml keyword">LinearLayout</code><code class="xml plain">&gt;</code></div><div class="line number19 index18 alt2"><code class="xml plain">&lt;/</code><code class="xml keyword">ScrollView</code><code class="xml plain">&gt;</code></div></div></td></tr></tbody></table></div></div>
<br><br>
With that, we have an application that we should be able to launch and 
run in the emulator, and it should look like the first screen shot we 
saw above - a basic black screen with white text and a few names as 
output. The names come from the database, which now exists, and now we 
can move on to using <b>sqlite3</b>. 
<br><br>
Android uses <a href="http://www.sqlite.org/">SQLite</a> as it's built 
in embedded database. If you need to store local application data, 
rather than going to simpler mechanisms like the file system, or more 
complicated means such as the network, you use the database. 
<br><br>
To examine the database we can login using the shell provided by the <a href="http://developer.android.com/intl/es/guide/developing/tools/adb.html">Android Debug Bridge</a>.
 To use this we need the "tools" folder of the SDK on our path (see the 
SDK documentation if you need more information about that). If we start 
the app in Eclipse (Run As -&gt; Android Application), and leave it 
running, we should then be able to login with the command:
<code>
</code><pre>ccollins@crotalus:~$ adb -e shell
# 
</pre>

The -e option tells ADB to use the emulator, rather than a possible 
connected device (and returns an error if more than one emulator is 
running). The "#" is the command prompt, we are logged in. 
<br><br>
Once logged in we can browse around with the "ls" command. The directory we are interested in is <b>/data/data/com.totsp.androidexamples/databases</b>
 (each application has a directory at the path /data/data/PACKAGE_NAME).
 We can change to that directory with the "cd" command. Once there we 
can use the command line SQLite tool, <b>sqlite3</b>, to examine our database, as follows:
<br>
<code>
</code><pre># sqlite3 example.db
SQLite version 3.5.9
Enter ".help" for instructions
sqlite&gt; select * from sqlite_master;
table|android_metadata|android_metadata|3|CREATE TABLE android_metadata (locale TEXT)
table|table1|table1|4|CREATE TABLE table1 (id INTEGER PRIMARY KEY, name TEXT)
sqlite&gt; 
</pre>

<br>
We login with "sqlite3 [database_name]" and then we can run basic SQL 
commands that are supported by SQLite (see the documentation there for 
full details). One handy table is the <b>sqlite_master</b> that we can see shows all the other tables inside our database. 
<br><br>
Some other interesting commands are:
<code>
</code><pre>sqlite&gt; .schema
CREATE TABLE android_metadata (locale TEXT);
CREATE TABLE table1 (id INTEGER PRIMARY KEY, name TEXT);
sqlite&gt; .tables
android_metadata  table1          
sqlite&gt; select * from table1;
1|Porky Pig
2|Foghorn Leghorn
3|Yosemite Sam
sqlite&gt; 
</pre>

<br>
We can use <b>.help</b> from within the sqlite3 shell (it has it's own 
shell, apart from the emulator shell we are logged in to), to see a full
 list of commands. Commands that start with "." are built in, and 
perform a function - such as <b>.schema</b> and <b>.tables</b> that we 
see above. SQL commands themselves can also be run directly by typing 
them in -- something we also see above (typed commands are run as soon 
as a ; is encountered and you press enter). 
<br><br>
With that, we have the basics. We have an application that creates a 
database and stores and retrieves data using it, and we have done a bit 
of exploring with the SQLite tools in ADB. In the future I hope to 
expand on this article and add some more involved tables, and further 
examples such as Android unit testing (another not so well documented, 
but extremely useful, part of the platform).  </div>
    
      <div class="nodeLinks">
      <ul class="links inline"><li class="blog_usernames_blog first"><a href="http://www.screaming-penguin.com/blog/1" title="Read charlie.collins's latest blog entries.">charlie.collins's blog</a></li>
<li class="comment_add last"><a href="http://www.screaming-penguin.com/comment/reply/7742#comment-form" title="Share your thoughts and opinions related to this posting.">Add new comment</a></li>
</ul>    </div>
    
</div>
<div id="comments"><h2 class="comments">Comments</h2><a id="comment-12179"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-12179" class="active">Thanks dude, your article was</a>  </h3>

  <div class="submitted">
    Submitted by Anonymous (not verified) on Thu, 02/18/2010 - 22:08.  </div>

  <div class="content">
    Thanks dude, your article was really helpful to me!
Indeed, Google could have done a better job documenting the database aspect of Android.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/12179">reply</a></li>
</ul>  </div>
</div><a id="comment-12261"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-12261" class="active">Thanks a lot..........</a>  </h3>

  <div class="submitted">
    Submitted by Paresh Mayani (not verified) on Thu, 03/04/2010 - 06:43.  </div>

  <div class="content">
    Actually, i am new in the android development,
so
This article help me lot to learn about android database...........      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/12261">reply</a></li>
</ul>  </div>
</div><a id="comment-12329"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-12329" class="active">Thanks.</a>  </h3>

  <div class="submitted">
    Submitted by Banker (not verified) on Tue, 03/30/2010 - 22:41.  </div>

  <div class="content">
    Stellar job.
Thanks for taking the time to do this.
-Banker      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/12329">reply</a></li>
</ul>  </div>
</div><a id="comment-12393"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-12393" class="active">This is a great tutorial</a>  </h3>

  <div class="submitted">
    Submitted by SEO Help (not verified) on Tue, 04/27/2010 - 08:23.  </div>

  <div class="content">
    You have just completed my understanding of android apps.
I have learnt alot from different tutorials but none really covered DB 
connections properly. Thanks for this. I realy appreciate it. Maybe you 
can do a tutorial on storing data using preferences next.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/12393">reply</a></li>
</ul>  </div>
</div><a id="comment-12500"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-12500" class="active">I want to view the database</a>  </h3>

  <div class="submitted">
    Submitted by Amit (not verified) on Mon, 05/24/2010 - 03:53.  </div>

  <div class="content">
    I want to view the database in SQL lite database browser, but the database does not appear in assets folder?      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/12500">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-12540"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-12540" class="active">I want to view the database </a>  </h3>

  <div class="submitted">
    Submitted by Vayu (not verified) on Fri, 05/28/2010 - 16:21.  </div>

  <div class="content">
    Thank  you for sharing your knowledge.
One can see the SQLLIte database file in DDMS.
Keep application running.Open DDMS,Select current application in "File 
Explorer" and navigate to "databases"  folder.There one can find the .db
 file.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/12540">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-12541"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-12541" class="active">I want to view the database </a>  </h3>

  <div class="submitted">
    Submitted by Vayu (not verified) on Fri, 05/28/2010 - 16:26.  </div>

  <div class="content">
    Correction to above reply
One can see the SQLLIte database file in DDMS.
Keep application running.Open DDMS,
Browse data/data/applicationname/databases folder in File Explorer  .There one can find the .db file.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/12541">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-12545"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-12545" class="active">Hello, that is w very helpful</a>  </h3>

  <div class="submitted">
    Submitted by <a href="http://www.diyetmutfagi.com/" rel="nofollow">Diyet</a> (not verified) on Sat, 05/29/2010 - 15:58.  </div>

  <div class="content">
    Hello, that is w very helpful article.. i translated that article and i liked it..
thak you very much..      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/12545">reply</a></li>
</ul>  </div>
</div><a id="comment-17364"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17364" class="active">View the database</a>  </h3>

  <div class="submitted">
    Submitted by Sathya (not verified) on Fri, 03/11/2011 - 13:27.  </div>

  <div class="content">
    Hi... It was highly useful... I need to see the .db file.. But in DDMS I could not find Databases ... Pls help..      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17364">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-17365"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17365" class="active">Got it!!!!</a>  </h3>

  <div class="submitted">
    Submitted by Sathya (not verified) on Fri, 03/11/2011 - 14:09.  </div>

  <div class="content">
    Thanks dude... I could see the database... Great work!!!!!!      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17365">reply</a></li>
</ul>  </div>
</div></div></div></div></div><a id="comment-15390"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-15390" class="active">This example works with Target 2.2?  Thanks for the post!</a>  </h3>

  <div class="submitted">
    Submitted by <a href="http://www.androiding.wordpress.com/" rel="nofollow">Roger</a> (not verified) on Thu, 07/29/2010 - 21:16.  </div>

  <div class="content">
    This example works with Target 2.2? Or any new version of android that will come?
Thanks for the post!      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/15390">reply</a></li>
</ul>  </div>
</div><a id="comment-15398"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-15398" class="active">Great article</a>  </h3>

  <div class="submitted">
    Submitted by Anonymous (not verified) on Mon, 08/09/2010 - 06:21.  </div>

  <div class="content">
    Thank you,
- again, like you mentioned, most tutorials involve contentproviders and
 what have you - this tutorial teaches us the very basic principles - 
which is absolutely puurrfect..
Thank you so much!      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/15398">reply</a></li>
</ul>  </div>
</div><a id="comment-15449"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-15449" class="active">Congratulations &amp; Query</a>  </h3>

  <div class="submitted">
    Submitted by Flexfusion (not verified) on Tue, 08/24/2010 - 14:50.  </div>

  <div class="content">
    Hi Charly, very good your explanation. Sorry, I need know where is 
obtain all commands for Android Emulator, relative reference about to 
this articles, so on. :)
Thank!      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/15449">reply</a></li>
</ul>  </div>
</div><a id="comment-15461"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-15461" class="active">simple and straightforward</a>  </h3>

  <div class="submitted">
    Submitted by Erik (not verified) on Thu, 08/26/2010 - 02:15.  </div>

  <div class="content">
    Thanks for this useful tutorial. It makes it much easier to 
understand what you really need to get going with database stuff than 
the examples provided with the Android SDK. 
To answer one of the previous comments this also works with API Level 8 
(Android 2.2) which is what I'm using.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/15461">reply</a></li>
</ul>  </div>
</div><a id="comment-15467"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-15467" class="active">Thanks a lot</a>  </h3>

  <div class="submitted">
    Submitted by <a href="http://www.mysmu.edu/phdis2008/payas.gupta.2008/default.htm" rel="nofollow">Payas Gupta</a> (not verified) on Sat, 08/28/2010 - 03:04.  </div>

  <div class="content">
    Thanks a lot man... this article really helped me a lot in understanding android databases      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/15467">reply</a></li>
</ul>  </div>
</div><a id="comment-16159"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16159" class="active">Thank you! This was simple</a>  </h3>

  <div class="submitted">
    Submitted by Anonymous (not verified) on Fri, 09/17/2010 - 23:58.  </div>

  <div class="content">
    Thank you! This was simple and very helpful.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16159">reply</a></li>
</ul>  </div>
</div><a id="comment-16193"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16193" class="active">Excellent !!</a>  </h3>

  <div class="submitted">
    Submitted by ram (not verified) on Mon, 09/20/2010 - 14:11.  </div>

  <div class="content">
    Excellent !!      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16193">reply</a></li>
</ul>  </div>
</div><a id="comment-16231"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16231" class="active">Question</a>  </h3>

  <div class="submitted">
    Submitted by Peter (not verified) on Fri, 09/24/2010 - 03:27.  </div>

  <div class="content">
    Hi,
I am using this tutorial to create a database with multiple rows. I'm a 
bit stuck though and hope someone will be able to answer my question.
I don't know how to alter the following code to insert multiple strings:
<code>
public long insert(String name) {
	      this.insertStmt.bindString(1, name);
	      return this.insertStmt.executeInsert();
	   }
</code>
I'm also wondering how to use the public List code, I want to show rows 
based on a query like SELECT * from TABLE_NAME where country = 
'NETHERLANDS', how would I do that?
I've already altered the rest of the code to my needs as seen below, not
 sure it works yet, though.
<code>
import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteStatement;
import android.util.Log;
import java.util.ArrayList;
import java.util.List;
public class DataHelper {
   private static final String DATABASE_NAME = "rooster.db";
   private static final int DATABASE_VERSION = 1;
   private static final String TABLE_NAME = "rooster";
   private Context context;
   private SQLiteDatabase db;
   private SQLiteStatement insertStmt;
   private static final String INSERT = "insert into "
      + TABLE_NAME + "(dag, vak, lokaal, begintijd, eindtijd, leraar)  
values (?, ?, ?, ?, ?, ?)";
   public DataHelper(Context context) {
      this.context = context;
      OpenHelper openHelper = new OpenHelper(this.context);
      this.db = openHelper.getWritableDatabase();
      this.insertStmt = this.db.compileStatement(INSERT);
   }
   public long insert(String dag, String vak, String lokaal, String 
begintijd, String eindtijd, String leraar) {
      this.insertStmt.bindString(1, dag);
      return this.insertStmt.executeInsert();
   }
   public void deleteAll() {
      this.db.delete(TABLE_NAME, null, null);
   }
   public List selectAll() {
      List list = new ArrayList();
      Cursor cursor = this.db.query(TABLE_NAME, new String[] { "name" },
        null, null, null, null, "id desc");
      if (cursor.moveToFirst()) {
         do {
            list.add(cursor.getString(0));
         } while (cursor.moveToNext());
      }
      if (cursor != null &amp;&amp; !cursor.isClosed()) {
         cursor.close();
      }
      return list;
   }
   private static class OpenHelper extends SQLiteOpenHelper {
      OpenHelper(Context context) {
         super(context, DATABASE_NAME, null, DATABASE_VERSION);
      }
      @Override
      public void onCreate(SQLiteDatabase db) {
         db.execSQL("CREATE TABLE " + TABLE_NAME + " (id INTEGER PRIMARY
 KEY, dag TEXT, vak TEXT, lokaal TEXT, begintijd TEXT, eindtijd TEXT, 
leraar TEXT)");
      }
      @Override
      public void onUpgrade(SQLiteDatabase db, int oldVersion, int 
newVersion) {
         Log.w("Example", "Upgrading database, this will drop tables and
 recreate.");
         db.execSQL("DROP TABLE IF EXISTS " + TABLE_NAME);
         onCreate(db);
      }
   }
}
</code>
Thanks in advance for your help!      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16231">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-16233"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16233" class="active">Keep in mind what I've done</a>  </h3>

  <div class="submitted">
    Submitted by charlie.collins on Fri, 09/24/2010 - 09:00.  </div>

  <div class="content">
    Keep in mind what I've done here is just a basic example. See the docs for all the stuff you can do: <a href="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html" title="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html">http://developer.android.com/reference/android/database/sqlite/SQLiteDat...</a>.
 
To bind multiple strings to one statement, just use bindString(1, 
firstName), bindString(2, lastName), where your statement has multiple 
placeholders (?s). 
Here's an example (see the insert method): <a href="http://code.google.com/p/and-bookworm/source/browse/trunk/src/com/totsp/bookworm/data/dao/BookDAO.java" title="http://code.google.com/p/and-bookworm/source/browse/trunk/src/com/totsp/bookworm/data/dao/BookDAO.java">http://code.google.com/p/and-bookworm/source/browse/trunk/src/com/totsp/...</a>
Also note that you don't *have* to use a SQLiteStatement. The statement 
is pre-compiled and will be a little faster if you use it over and over 
again, but there is also a plain "insert" method: 
http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html#insert(java.lang.String,
 java.lang.String, android.content.ContentValues)      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16233">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-16234"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16234" class="active">Thank you so much! I'll be</a>  </h3>

  <div class="submitted">
    Submitted by Peter (not verified) on Fri, 09/24/2010 - 10:36.  </div>

  <div class="content">
    Thank you so much! I'll be looking into it.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16234">reply</a></li>
</ul>  </div>
</div></div><a id="comment-16235"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16235" class="active">Hi, i also want to knw how to</a>  </h3>

  <div class="submitted">
    Submitted by ALi (not verified) on Fri, 09/24/2010 - 13:12.  </div>

  <div class="content">
    Hi, i also want to knw how to add 2 or more columns using your code. Thanks      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16235">reply</a></li>
</ul>  </div>
</div></div><a id="comment-16238"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16238" class="active">Great!!!  tutorial </a>  </h3>

  <div class="submitted">
    Submitted by Ronic (not verified) on Sat, 09/25/2010 - 07:24.  </div>

  <div class="content">
    superb!!! work
simple but very useful...
Thanks a lot...
Ronic      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16238">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-16974"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16974" class="active">Excellent tutorial indeed!</a>  </h3>

  <div class="submitted">
    Submitted by hlt (not verified) on Thu, 12/09/2010 - 16:34.  </div>

  <div class="content">
    It makes it much easier to understand what you really need to get 
going with database stuff than the examples provided with the Android 
SDK.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16974">reply</a></li>
</ul>  </div>
</div></div><a id="comment-16240"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16240" class="active">I now got as far as being</a>  </h3>

  <div class="submitted">
    Submitted by Peter (not verified) on Mon, 09/27/2010 - 02:11.  </div>

  <div class="content">
    I now got as far as being able to insert multiple columns in the 
database. The only thing I'm still struggling with is viewing all the 
data. I only am able to show 1 column from the database with the 
following code:
<code>
this.output = (TextView) this.findViewById(R.id.out_text);
this.dh = new DataHelper(this);
    List lesuren = this.dh.selectAll();
    StringBuilder sb = new StringBuilder();
    sb.append("Names in database:\n");
    for (String address: addresses) {
       sb.append("address: " + address+ "\n");
    }
    this.output.setText(sb.toString());
</code>
And in DataHelper.java:
<code>
public List selectAll() {
      List list = new ArrayList();
      Cursor cursor = this.db.query(TABLE_NAME, new String[] { "address" },
        null, null, null, null, "addressasc");
      if (cursor.moveToFirst()) {
         do {
            list.add(cursor.getString(0));
         } while (cursor.moveToNext());
      }
      if (cursor != null &amp;&amp; !cursor.isClosed()) {
         cursor.close();
      }
      return list;
   }
</code>
I would be very grateful if someone can help me out with this.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16240">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-16250"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16250" class="active">Check the docs, a lot of</a>  </h3>

  <div class="submitted">
    Submitted by charlie.collins on Tue, 09/28/2010 - 12:53.  </div>

  <div class="content">
    Check the docs, a lot of helpful stuff is in there. 
But to go ahead an bite, without carefully reviewing your code, this 
might be the right direction (disclaimer, did I say check the docs?):
...
// the second element to the query method is an array of the columns you
 want to retrieve
Cursor cursor = this.db.query(TABLE_NAME, new String[] { "address", 
"fname", "lname" },
null, null, null, null, "addressasc");
if (cursor.moveToFirst()) {
do {
list.add(cursor.getString(0)); // address
list.add(cursor.getString(1)); // fname
list.add(cursor.getString(2)); // lname
...
<a href="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html" title="http://developer.android.com/reference/android/database/sqlite/SQLiteDatabase.html">http://developer.android.com/reference/android/database/sqlite/SQLiteDat...</a>      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16250">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-16254"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16254" class="active">Thanks, I already had found</a>  </h3>

  <div class="submitted">
    Submitted by Peter (not verified) on Wed, 09/29/2010 - 03:01.  </div>

  <div class="content">
    Thanks, I already had found the solution, just like you're example, 
so it's working now. Now I'm gonna figure out how to put it in a nice 
grid and being able to do a query like: SELECT * from TABLE_NAME where 
day = 'monday'.
Thanks for your help.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16254">reply</a></li>
</ul>  </div>
</div></div></div><a id="comment-16263"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16263" class="active">Great example, a very good start point</a>  </h3>

  <div class="submitted">
    Submitted by David (not verified) on Tue, 10/05/2010 - 21:32.  </div>

  <div class="content">
    It's a fact that the Android docs are horrible to anyone who is 
starting at anything. It's not beginner-oriented, and that is to be 
expected somewhat.
When I learned how to use SQLite3 with Android, the only example that 
really did for me was yours.
I actually use the same methodology I learned with you to this very day.
Of course, many of my projects are huge behemoths, but the skeleton is 
still the same of your example.
Thank you very much. You don't know how much you helped me.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16263">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-16362"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16362" class="active">I know this article isn't</a>  </h3>

  <div class="submitted">
    Submitted by charlie.collins on Thu, 10/07/2010 - 07:49.  </div>

  <div class="content">
    I know this article isn't perfect, but glad to hear it helped, and thanks for saying thanks.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16362">reply</a></li>
</ul>  </div>
</div></div><a id="comment-16264"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16264" class="active">Database in Gridview?</a>  </h3>

  <div class="submitted">
    Submitted by Peter (not verified) on Wed, 10/06/2010 - 04:44.  </div>

  <div class="content">
    Does anyone know how to put the database entries into a gridview? Or
 is there a tutorial out there which explains how to do that. I've 
followed the Gridview documentation on developer.android.com, and 
succeeded into loading text into the gridview, but not the text my 
database contains.
My gridview code at this time:
<pre>import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.GridView;
import android.widget.TextView;

public class ImageAdapter extends BaseAdapter {
    private Context context;

  public ImageAdapter(Context context) {
        this.context = context;
    }

   public int getCount() {
        return 4;
    }


    public Object getItem(int position) {
        return null;
    }

   public long getItemId(int position) {
        return 0;
    }

    // create a new ImageView for each item referenced by the Adapter
    public View getView(int position, View convertView, ViewGroup parent) {
        TextView tv;
        if (convertView == null) {
            tv = new TextView(context);
            tv.setLayoutParams(new GridView.LayoutParams(60, 25));
        }
        else {
            tv = (TextView) convertView;
        }

        tv.setText(texts[position]);
        return tv;
        
    }
    
    private String[] texts = {"PWU", "10:00", "10:45", "Boukiour"};

}
</pre>
Thanks in advance for your help!      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16264">reply</a></li>
</ul>  </div>
</div><a id="comment-16368"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16368" class="active">Thanks for the tutorial!</a>  </h3>

  <div class="submitted">
    Submitted by Kurt (not verified) on Mon, 10/11/2010 - 00:06.  </div>

  <div class="content">
    Thanks for the tutorial! Helped me a lot.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16368">reply</a></li>
</ul>  </div>
</div><a id="comment-16414"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16414" class="active">Thanks</a>  </h3>

  <div class="submitted">
    Submitted by <a href="http://cymox1.blogspot.com/" rel="nofollow">Simon Ndunda</a> (not verified) on Sun, 10/24/2010 - 11:32.  </div>

  <div class="content">
    This is exactly what i was looking for, i ran your code 
successfully, and based on my previous programming experience in other 
platforms(Other than android) i am able to modify it to fit my android 
application's needs. Thanks.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16414">reply</a></li>
</ul>  </div>
</div><a id="comment-16460"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16460" class="active">Where is database (if i am using sqlite browser)?</a>  </h3>

  <div class="submitted">
    Submitted by Anonymous (not verified) on Wed, 10/27/2010 - 01:51.  </div>

  <div class="content">
    I am using an sqlite browser in MAC. I want to this database to open
 in my browser..? will you please help? where the file actually stored? 
     </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16460">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-16493"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16493" class="active">To use something like SQLite</a>  </h3>

  <div class="submitted">
    Submitted by charlie.collins on Wed, 10/27/2010 - 07:50.  </div>

  <div class="content">
    To use something like SQLite Manager (<a href="http://code.google.com/p/sqlite-manager/" title="http://code.google.com/p/sqlite-manager/">http://code.google.com/p/sqlite-manager/</a>), which can be handy, you'll have to copy the DB file over. You can't connect directly to it. 
And this article explains exactly where the file is stored.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16493">reply</a></li>
</ul>  </div>
</div></div><a id="comment-16500"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16500" class="active">Thumbs up</a>  </h3>

  <div class="submitted">
    Submitted by Steven (not verified) on Thu, 10/28/2010 - 13:04.  </div>

  <div class="content">
    Much more useful than any of the documentation provided by Google, thanks very much :)      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16500">reply</a></li>
</ul>  </div>
</div><a id="comment-16861"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16861" class="active">Awesome tutorial</a>  </h3>

  <div class="submitted">
    Submitted by madcoderz (not verified) on Tue, 11/16/2010 - 04:26.  </div>

  <div class="content">
    I just wanted to thank you for the greatest tutorial ever. It really helped. It's simple and truly understandable.
Thanks a lot      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16861">reply</a></li>
</ul>  </div>
</div><a id="comment-16862"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16862" class="active">Thankyou Man!</a>  </h3>

  <div class="submitted">
    Submitted by Hunt (not verified) on Tue, 11/16/2010 - 10:23.  </div>

  <div class="content">
    This tutorial had greatly helped me. Keep the good/Great stuff going on man. Hope you achieve greater heights. :-)      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16862">reply</a></li>
</ul>  </div>
</div><a id="comment-16983"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16983" class="active">Unable to view database</a>  </h3>

  <div class="submitted">
    Submitted by anil (not verified) on Thu, 12/23/2010 - 05:41.  </div>

  <div class="content">
    Hi,
 I have created exact copy of this application. but as you said "a basic
 black screen with white text and a few names" will come  as output, but
 i am not getting it in my emulator.
next when i give ls data/data in cmd. i can find package 
"com.totsp.androidexamples" but when i give " ls 
/data/data/com.totsp.androidexamples/databases " i get the message "No 
such file or directory" 
even i went to windows explorer of ddms and clicked on data/data. i 
found only package name when i placed cursor above com file. but couldnt
 find any .db file.
can you please tell me why this is happening and how can i solve my prob
Thanks      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16983">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-17011"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17011" class="active">Unable to view database</a>  </h3>

  <div class="submitted">
    Submitted by Robert (not verified) on Tue, 01/11/2011 - 14:58.  </div>

  <div class="content">
    This will happen to you if you mess up project creation in Eclipse. 
The .png file is to small to actually read project configuration, but 
click generate activity and name it Main. I tried manually correcting 
the manifest, but gave up and created a new project and copied over all 
my source.  Works great now.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17011">reply</a></li>
</ul>  </div>
</div></div><a id="comment-16994"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16994" class="active">It really helped me a lot,</a>  </h3>

  <div class="submitted">
    Submitted by Himanth (not verified) on Fri, 01/07/2011 - 03:53.  </div>

  <div class="content">
    It really helped me a lot, thank u so much.. keep doing ur job...      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16994">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-16995"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16995" class="active">Thanks</a>  </h3>

  <div class="submitted">
    Submitted by Kumar (not verified) on Fri, 01/07/2011 - 03:56.  </div>

  <div class="content">
    Ne nalla iruppa da.. romba supera sollirukka..  thanks machi..      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16995">reply</a></li>
</ul>  </div>
</div></div><a id="comment-16996"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-16996" class="active">awesome</a>  </h3>

  <div class="submitted">
    Submitted by vicky (not verified) on Fri, 01/07/2011 - 04:18.  </div>

  <div class="content">
    it was very useful....... thanks for such program      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/16996">reply</a></li>
</ul>  </div>
</div><a id="comment-17003"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17003" class="active">Thanks!</a>  </h3>

  <div class="submitted">
    Submitted by kevin (not verified) on Mon, 01/10/2011 - 17:45.  </div>

  <div class="content">
    Ah, <em>now<em> I get it!
Thanks for the clear and simple tutorial.  I'm glad I came across this page.</em></em>      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17003">reply</a></li>
</ul>  </div>
</div><a id="comment-17010"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17010" class="active">error help</a>  </h3>

  <div class="submitted">
    Submitted by Anonymous (not verified) on Tue, 01/11/2011 - 06:44.  </div>

  <div class="content">
    this.input = (EditText) this.findViewById(R.id.in_text);
      this.saveButton = (Button) this.findViewById(R.id.save_button);
      this.deleteButton = (Button) this.findViewById(R.id.del_button);
      this.output = (TextView) this.findViewById(R.id.out_text);
in_text cannot be resolved or is not a field
i do not know what to do with this error.
please help.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17010">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-17012"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17012" class="active">error help</a>  </h3>

  <div class="submitted">
    Submitted by Robert (not verified) on Tue, 01/11/2011 - 15:05.  </div>

  <div class="content">
    R.java is a generated resource file which lives in gen/.  
R.id.in_text would come from your xml definitions. Make sure your 
res/layout/main.xml has a section like: android:id="@+id/in_text".
Robert      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17012">reply</a></li>
</ul>  </div>
</div><div class="indented"><a id="comment-17068"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17068" class="active">As you mentioned the</a>  </h3>

  <div class="submitted">
    Submitted by Anonymous (not verified) on Thu, 01/27/2011 - 10:32.  </div>

  <div class="content">
    As you mentioned the res/layout/main.xml has a section like: android:id="@+id/in_text".
and for every other corresponding id.
still it is showing an error.
what could be the reason.
and thanks for your help.      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17068">reply</a></li>
</ul>  </div>
</div></div></div><a id="comment-17040"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17040" class="active">A few questions...</a>  </h3>

  <div class="submitted">
    Submitted by Alice (not verified) on Sat, 01/15/2011 - 22:16.  </div>

  <div class="content">
    I noticed that there is this "sqlite" thingy inside the tools folder
 in the android sdk, does that mean that I don't have to install sqlite 
separately? 
Also, why does the app need to create the DB through code? Can't we 
access a pre populated DB and access it from there?      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17040">reply</a></li>
</ul>  </div>
</div><a id="comment-17061"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17061" class="active">Great tutorial!</a>  </h3>

  <div class="submitted">
    Submitted by Sally (not verified) on Sun, 01/23/2011 - 09:02.  </div>

  <div class="content">
    Many thanks for the tutorial. It is very well done. As for me, I used this video tutorial <a href="http://www.tubestime.com/watch/android-database-sqlite-tutorial" title="http://www.tubestime.com/watch/android-database-sqlite-tutorial">http://www.tubestime.com/watch/android-database-sqlite-tutorial</a>
 but there were a lot of points I couldn't fullfill. You are right 
sometimes the tutorials are more complicated that they are needed to be.
Thanks for giving us the alternative!      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17061">reply</a></li>
</ul>  </div>
</div><a id="comment-17069"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17069" class="active">This tutorial saves lives</a>  </h3>

  <div class="submitted">
    Submitted by Anonymous (not verified) on Thu, 01/27/2011 - 20:06.  </div>

  <div class="content">
    Thank you so much for making this tutorial. Not only did it save 
hours and hours of time, but it gave me a strong foundation to build off
 of.
Thank you again!!!      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17069">reply</a></li>
</ul>  </div>
</div><a id="comment-17072"></a>
<div class="comment comment-published odd">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17072" class="active">SQLite database</a>  </h3>

  <div class="submitted">
    Submitted by Anonymous (not verified) on Fri, 01/28/2011 - 15:10.  </div>

  <div class="content">
    I have tried several tutorials for android for SQLite but the 
database does not load at all.  There is no folder databases with the 
file name. 
I do have mySQL on machine.  Is that maybe why this won't work. 
Can someone help with how to get SQLite to work with android.
thanks,
alex      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17072">reply</a></li>
</ul>  </div>
</div><a id="comment-17139"></a>
<div class="comment comment-published even">
  
  
  
  <h3 class="commen-title">
    <a href="http://www.screaming-penguin.com/node/7742#comment-17139" class="active">I try to instantiate the</a>  </h3>

  <div class="submitted">
    Submitted by suntzu on Mon, 02/07/2011 - 06:12.  </div>

  <div class="content">
    I try to instantiate the DataHelper on the Application but the constructor of DataHelper require a context
I try getApplicationContext() but does'nt works :(
any suggestion?
Thanks in advance      </div>

  <div class="links">
    <ul class="links"><li class="comment_reply first last"><a href="http://www.screaming-penguin.com/comment/reply/7742/17139">reply</a></li>
</ul>  </div>
</div><div class="item-list"><ul class="pager"><li class="pager-current first">1</li>
<li class="pager-item"><a href="http://www.screaming-penguin.com/node/7742?page=1" title="Go to page 2" class="active">2</a></li>
<li class="pager-next"><a href="http://www.screaming-penguin.com/node/7742?page=1" title="Go to next page" class="active">next ›</a></li>
<li class="pager-last last"><a href="http://www.screaming-penguin.com/node/7742?page=1" title="Go to last page" class="active">last »</a></li>
</ul></div><form action="/node/7742" accept-charset="UTF-8" method="post" id="comment-controls">
<div>  <div class="box">
    <h2 class="title">Comment viewing options</h2>    <div class="content"><div class="container-inline"><input name="form_build_id" id="form-639580316e2ea17b71a20565575c7c53" value="form-639580316e2ea17b71a20565575c7c53" type="hidden">
<input name="form_id" id="edit-comment-controls" value="comment_controls" type="hidden">
<div class="form-item" id="edit-mode-wrapper">
 <select name="mode" class="form-select" id="edit-mode"><option value="1">Flat list - collapsed</option><option value="2">Flat list - expanded</option><option value="3">Threaded list - collapsed</option><option value="4" selected="selected">Threaded list - expanded</option></select>
</div>
<div class="form-item" id="edit-order-wrapper">
 <select name="order" class="form-select" id="edit-order"><option value="1">Date - newest first</option><option value="2" selected="selected">Date - oldest first</option></select>
</div>
<div class="form-item" id="edit-comments-per-page-wrapper">
 <select name="comments_per_page" class="form-select" id="edit-comments-per-page"><option value="10">10 comments per page</option><option value="30">30 comments per page</option><option value="50" selected="selected">50 comments per page</option><option value="70">70 comments per page</option><option value="90">90 comments per page</option><option value="150">150 comments per page</option><option value="200">200 comments per page</option><option value="250">250 comments per page</option><option value="300">300 comments per page</option></select>
</div>
<input name="op" id="edit-submit" value="Save settings" class="form-submit" type="submit">
</div><div class="description">Select your preferred way to display the comments and click "Save settings" to activate your changes.</div></div>
 </div>


</div></form>
</div>        <div id="block-block-12" class="clear-block block block-block">


  <div class="content"><script type="text/javascript" src="database_files/plusone.js"></script>
<div style="height: 24px; width: 106px; display: inline-block; text-indent: 0pt; margin: 0pt; padding: 0pt; background: none repeat scroll 0% 0% transparent; border-style: none; float: none; line-height: normal; font-size: 1px; vertical-align: baseline;" id="___plusone_0"><iframe allowtransparency="true" hspace="0" id="I1_1321350254148" marginheight="0" marginwidth="0" name="I1_1321350254148" src="database_files/fastbutton.htm" style="position: static; left: 0pt; top: 0pt; width: 106px; margin: 0px; border-style: none; height: 24px; visibility: visible;" tabindex="-1" vspace="0" title="+1" width="100%" frameborder="0" scrolling="no"></iframe></div></div>
</div>
              </div><!-- /content -->

      <div id="sidebar-wrapper">
        <div id="sidebar">
                    <div id="block-user-1" class="clear-block block block-user">

  <h2 class="title">Navigation</h2>

  <div class="content"><ul class="menu"><li class="leaf first"><a href="http://www.screaming-penguin.com/tracker">Recent content</a></li>
<li class="leaf"><a href="http://www.screaming-penguin.com/tagadelic">Tags</a></li>
<li class="collapsed"><a href="http://www.screaming-penguin.com/aggregator">News aggregator</a></li>
<li class="leaf last"><a href="http://www.screaming-penguin.com/glossary">Glossary</a></li>
</ul></div>
</div>
<div id="block-user-0" class="clear-block block block-user">

  <h2 class="title">User login</h2>

  <div class="content"><form action="/node/7742?destination=node%2F7742" accept-charset="UTF-8" method="post" id="user-login-form">
<div><div class="form-item" id="edit-openid-identifier-wrapper">
 <label for="edit-openid-identifier">Log in using OpenID: </label>
 <input maxlength="255" name="openid_identifier" id="edit-openid-identifier" size="13" class="form-text" type="text">
 <div class="description"><a href="http://openid.net/">What is OpenID?</a></div>
</div>
<div class="form-item" id="edit-name-wrapper">
 <label for="edit-name">Username: <span class="form-required" title="This field is required.">*</span></label>
 <input maxlength="60" name="name" id="edit-name" size="15" class="form-text required" type="text">
</div>
<div class="form-item" id="edit-pass-wrapper">
 <label for="edit-pass">Password: <span class="form-required" title="This field is required.">*</span></label>
 <input name="pass" id="edit-pass" maxlength="60" size="15" class="form-text required" type="password">
</div>
<input name="op" id="edit-submit-1" value="Log in" class="form-submit" type="submit">
<input name="form_build_id" id="form-0764fc55504c69a5b1117fb7565c9e12" value="form-0764fc55504c69a5b1117fb7565c9e12" type="hidden">
<input name="form_id" id="edit-user-login-block" value="user_login_block" type="hidden">
<input name="openid.return_to" id="edit-openid.return-to" value="http://www.screaming-penguin.com/openid/authenticate?destination=node%2F7742" type="hidden">
<div class="item-list"><ul><li class="openid-link first openid-processed"><a href="http://www.screaming-penguin.com/%2523">Log in using OpenID</a></li>
<li class="user-link last openid-processed"><a href="http://www.screaming-penguin.com/%2523">Cancel OpenID login</a></li>
</ul></div><div class="item-list"><ul><li class="first"><a href="http://www.screaming-penguin.com/user/register" title="Create a new user account.">Create new account</a></li>
<li class="last"><a href="http://www.screaming-penguin.com/user/password" title="Request new password via e-mail.">Request new password</a></li>
</ul></div>
</div></form>
</div>
</div>
<div id="block-block-1" class="clear-block block block-block">

  <h2 class="title">Community</h2>

  <div class="content"><a href="http://fedora.redhat.com/"><img src="database_files/fedora.png" alt="community"></a><br></div>
</div>
<div id="block-comment-0" class="clear-block block block-comment">

  <h2 class="title">Recent comments</h2>

  <div class="content"><div class="item-list"><ul><li class="first"><a href="http://www.screaming-penguin.com/node/7742#comment-18401" class="active">Thanks you :)</a><br>3 weeks 5 days ago</li>
<li><a href="http://www.screaming-penguin.com/node/6000#comment-18399">Yahoo email locked out</a><br>3 weeks 5 days ago</li>
<li><a href="http://www.screaming-penguin.com/node/7718#comment-18230">same thing</a><br>7 weeks 6 days ago</li>
<li><a href="http://www.screaming-penguin.com/node/7409#comment-17868">Using a 
"&gt;PS3 controller</a><br>10 weeks 1 hour ago</li>
<li><a href="http://www.screaming-penguin.com/node/7742#comment-17866" class="active">Thanks!</a><br>10 weeks 12 hours ago</li>
<li><a href="http://www.screaming-penguin.com/node/7856#comment-17861">Formatting is also messed up after restore</a><br>12 weeks 4 days ago</li>
<li><a href="http://www.screaming-penguin.com/node/7856#comment-17859">Oh, and one other comment,</a><br>13 weeks 2 days ago</li>
<li><a href="http://www.screaming-penguin.com/node/7856#comment-17858">Found old scream db from</a><br>13 weeks 2 days ago</li>
<li><a href="http://www.screaming-penguin.com/node/7856#comment-17857">Also, the FILE backups were</a><br>13 weeks 2 days ago</li>
<li class="last"><a href="http://www.screaming-penguin.com/node/6475#comment-17846">I recently gained 15lbs due to Diet Coke</a><br>17 weeks 5 days ago</li>
</ul></div></div>
</div>
<div id="block-block-11" class="clear-block block block-block">


  <div class="content"><a href="http://www.screaming-penguin.com/node/7786"><img src="database_files/collins_aip.jpg" alt="Android in Practice"></a><br>
<a href="http://www.manning.com/collins/">Android in Practice at Manning</a><br>
<a href="http://www.amazon.com/Android-Practice-Charlie-Collins/dp/1935182927">Android in Practice at Amazon</a></div>
</div>
<div id="block-block-2" class="clear-block block block-block">


  <div class="content"><a href="http://www.screaming-penguin.com/GWTinPractice"><img src="database_files/gwtip.png" alt="GWT In Practice"></a><br>
<a href="http://www.manning.com/cooper/">GWT in Practice at Manning</a><br>
<a href="http://www.amazon.com/GWT-Practice-Robert-Cooper/dp/1933988290">GWT in Practice at Amazon</a><br>
<b><a href="http://www.screaming-penguin.com/GWTResources">GWT Resources</a></b></div>
</div>
<div id="block-block-8" class="clear-block block block-block">


  <div class="content"><a href="http://www.screaming-penguin.com/UnlockingAndroid"><img src="database_files/uad_cover_163.jpg" alt="Unlocking Android"></a><br>
<a href="http://www.manning.com/ableson/">Unlocking Android at Manning</a><br>
<a href="http://www.amazon.com/Unlocking-Android-Frank-Ableson/dp/1933988673/">Unlocking Android at Amazon</a><br>
<b><a href="http://www.screaming-penguin.com/AndroidResources">Android Resources</a></b></div>
</div>
<div id="block-block-10" class="clear-block block block-block">


  <div class="content"><img src="database_files/twitter.png" alt="twitter"><br>
<a href="http://twitter.com/CharlieCollins">CharlieCollins</a><br>
<a href="http://twitter.com/kebernet">Kebernet</a></div>
</div>
        </div><!-- /sidebar -->
      </div><!-- /sidebar-wrapper -->
      
      <div id="footer">
        <div>
<a href="http://feeds.feedburner.com/screaming-penguin" title="Subscribe to my feed" rel="alternate" type="application/rss+xml"><img src="database_files/rss_75x75.png" alt=""></a><a href="http://feeds.feedburner.com/screaming-penguin" title="Subscribe to my feed" rel="alternate" type="application/rss+xml">Subscribe in a reader</a>
&nbsp;&nbsp;&nbsp;
</div>
<div>
This work is licensed under a <a rel="license" href="http://creativecommons.org/licenses/by-sa/2.0/">Creative Commons License</a>.
</div>
<div>1998-2010 <a href="http://www.screaming-penguin.com/">temple of the screaming penguin</a></div>              </div><!-- /footer -->
    </div><!-- /container -->
    <script type="text/javascript" src="database_files/google_cse.js"></script>
<script type="text/javascript" src="database_files/syntaxhighlighter.js"></script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
jQuery.extend(Drupal.settings, { "googleCSE": { "language": "en" } });
//--><!]]>
</script>
<script type="text/javascript">
<!--//--><![CDATA[//><!--
var _gaq = _gaq || [];_gaq.push(["_setAccount", "UA-90145-1"]);_gaq.push(["_trackPageview"]);(function() {var ga = document.createElement("script");ga.type = "text/javascript";ga.async = true;ga.src = "/files/googleanalytics/ga.js?8";var s = document.getElementsByTagName("script")[0];s.parentNode.insertBefore(ga, s);})();
//--><!]]>
</script>
  </body></html>